package com.supor.aiot.common.adapter;

import androidx.databinding.ViewDataBinding;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.lifecycle.AndroidViewModel;
import androidx.viewbinding.ViewBinding;

import com.android.baseconfig.base.BaseFragment;
import com.supor.aiot.common.R;
import com.supor.aiot.common.adapter.IconPagerAdapter;
import com.supor.aiot.common.base.BaseMVVMFragment;

import java.util.List;

/**
 * Created by zook on 2021/10/14.
 */

public class PagerTabFragmentAdapter<T extends BaseMVVMFragment<? extends AndroidViewModel, ? extends ViewDataBinding>>
        extends FragmentPagerAdapter implements IconPagerAdapter {
    protected List<T> list;

    public PagerTabFragmentAdapter(FragmentManager fm) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
    }

    public PagerTabFragmentAdapter(FragmentManager fm, List<T> list) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.list = list;
    }

    @Override
    public Fragment getItem(int arg0) {
        return list.get(arg0);
    }

    @Override
    public int getIconResId(int index) {
        return R.drawable.shape_calendar_blue;
    }

    @Override
    public int getCount() {
        return list.size();
    }

//    @Override
//    public CharSequence getPageTitle(int position) {
//        return (list.get(position)).getPagTitle();
//    }

    public List<T> getDatas() {
        return list;
    }
}

